package com.sky.controller.user;

import com.sky.web.controller.BaseController;
import com.sky.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @Author tzl
 * @Date 2023-07-09 16:23:51  星期日
 * @Description: 店铺相关接口
 */
@Slf4j
@Api(tags = "店铺相关接口")
@RestController("userShopController")
@RequestMapping("/user/shop")
public class ShopController extends BaseController {

    public static final String KEY = "SHOP_STATUS";

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    @GetMapping("/status")
    @ApiOperation("获取店铺状态")
    public AjaxResult getShopStatus(){
        Object shopStatus = redisTemplate.opsForValue().get(KEY);
        int status = 0;
        if (shopStatus != null) {
            status = Integer.parseInt(shopStatus.toString());
        }
        log.info("获取店铺状态：{},",status == 1 ?"营业中":"打洋中");
        return AjaxResult.success(status);
    }
}
